//
//  WXPNotAuthHomeMoneyView.m
//  顶部的金额-时间-利率-步骤
//
//  Created by WXP on 2025/2/27.
//
//

#import "WXPNotAuthHomeMoneyView.h"

@interface WXPNotAuthHomeMoneyView ()

@end

@implementation WXPNotAuthHomeMoneyView

#pragma mark - lazy
- (UIView *)viewBack{
    if (_viewBack == nil) {
        _viewBack = [UIView new];
        _viewBack.backgroundColor = COLOR_WHITE;
        [GlobalMethod setRoundView:_viewBack color:[UIColor clearColor] numRound:16 width:0];
        _viewBack.userInteractionEnabled = true;
        _viewBack.width = SCREEN_WIDTH-2*LEFT_MARDIN;
    }
    return _viewBack;
}
- (UILabel *)labelTitle{
    if (_labelTitle == nil) {
        _labelTitle = [UILabel new];
        _labelTitle.textColor = COLOR_CONTENT;
        _labelTitle.fontNum = 14;
        [_labelTitle fitTitle:@"Cuota máxima($)" variable:0];
    }
    return _labelTitle;
}
- (UILabel *)labelMoney{
    if (_labelMoney == nil) {
        _labelMoney = [UILabel new];
        _labelMoney.textColor = COLOR_BLACK;
        _labelMoney.font = [UIFont boldSystemFontOfSize:66];
        [_labelMoney fitTitle:@"* * *" variable:0];
    }
    return _labelMoney;
}
- (UILabel *)labelTimeTitle{
    if (_labelTimeTitle == nil) {
        _labelTimeTitle = [UILabel new];
        _labelTimeTitle.textColor = COLOR_CONTENT;
        _labelTimeTitle.fontNum = 12;
        [_labelTimeTitle fitTitle:@"Plazo de préstamo" variable:0];
    }
    return _labelTimeTitle;
}
- (UILabel *)labelTime{
    if (_labelTime == nil) {
        _labelTime = [UILabel new];
        _labelTime.textColor = COLOR_BLACK;
        _labelTime.font = [UIFont boldSystemFontOfSize:16];
    }
    return _labelTime;
}
- (UILabel *)labelRateTitle{
    if (_labelRateTitle == nil) {
        _labelRateTitle = [UILabel new];
        _labelRateTitle.textColor = COLOR_CONTENT;
        _labelRateTitle.fontNum = 12;
        [_labelRateTitle fitTitle:@"Tasa de Interés" variable:0];
    }
    return _labelRateTitle;
}
- (UILabel *)labelRate{
    if (_labelRate == nil) {
        _labelRate = [UILabel new];
        _labelRate.textColor = COLOR_BLACK;
        _labelRate.font = [UIFont boldSystemFontOfSize:16];
    }
    return _labelRate;
}
-(UIButton *)btnAuth{
    if (_btnAuth == nil) {
        _btnAuth = [UIButton buttonWithType:UIButtonTypeCustom];
        WEAKSELF
        [_btnAuth setNoRepeatActionWithInterval:1 action:^(UIButton * _Nonnull button) {
            [NSObject clickFeedback];
            [weakSelf.btnAuth addClickAnimate];
            if(weakSelf.blockJumpAuth){
                weakSelf.blockJumpAuth();
            }
        }];
        _btnAuth.backgroundColor = COLOR_PRIMARY;
        _btnAuth.titleLabel.font = [UIFont systemFontOfSize:14];
        _btnAuth.widthHeight = XY(self.viewBack.width-2*LEFT_MARDIN, BUTTON_HEIGHT);
        [GlobalMethod setRoundView:_btnAuth color:[UIColor clearColor] numRound:_btnAuth.height/2 width:0];
        _btnAuth.titleLabel.fontNum = 14;
        [_btnAuth setTitleColor:COLOR_BLACK forState:UIControlStateNormal];
        [_btnAuth setTitle:@"Lograr mi cuota" forState:(UIControlStateNormal)];
    }
    return _btnAuth;
}
- (UIImageView *)imagePasosBack{
    if (_imagePasosBack == nil) {
        _imagePasosBack = [UIImageView new];
        _imagePasosBack.image = [UIImage imageNamed:@"icon-home-border"];
        _imagePasosBack.widthHeight = XY(self.viewBack.width-2*LEFT_MARDIN, (self.viewBack.width-2*LEFT_MARDIN)/939*378);
    }
    return _imagePasosBack;
}
- (UILabel *)labelPasosTitle{
    if (_labelPasosTitle == nil) {
        _labelPasosTitle = [UILabel new];
        _labelPasosTitle.textColor = COLOR_LIGHT_GRAY;
        _labelPasosTitle.fontNum = 12;
        [_labelPasosTitle fitTitle:@"Solo tres pasos" variable:0];
    }
    return _labelPasosTitle;
}


#pragma mark - 初始化
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.width = SCREEN_WIDTH;
        [self addSubView];
    }
    return self;
}

//添加subview
- (void)addSubView{
    [self addSubview:self.viewBack];
    [self.viewBack addSubview:self.labelTitle];
    [self.viewBack addSubview:self.labelMoney];
    [self.viewBack addSubview:self.labelTimeTitle];
    [self.viewBack addSubview:self.labelTime];
    [self.viewBack addSubview:self.labelRateTitle];
    [self.viewBack addSubview:self.labelRate];
    [self.viewBack addSubview:self.btnAuth];
    [self.viewBack addSubview:self.imagePasosBack];
    [self.imagePasosBack addSubview:self.labelPasosTitle];
    [self resetView];
}

#pragma mark - 刷新view
- (void)resetView{
    self.labelTitle.centerXTop = XY(self.viewBack.width/2, Ratio(45));
    self.labelMoney.centerXTop = XY(self.viewBack.width/2, self.labelTitle.bottom+Ratio(12));

    self.labelTimeTitle.leftTop = XY(51, self.labelMoney.bottom);
    self.labelRateTitle.leftCenterY = XY(self.labelTimeTitle.right+36, self.labelTimeTitle.centerY);
    [self.labelTime fitTitle:@"120 Días" variable:0];
    [self.labelRate fitTitle:@"0.05% Por día" variable:0];
    self.labelTime.leftTop = XY(self.labelTimeTitle.left, self.labelTimeTitle.bottom+Ratio(5));
    self.labelRate.leftCenterY = XY(self.labelRateTitle.left, self.labelTime.centerY);
    
    self.btnAuth.centerXTop = XY(self.viewBack.width/2, self.labelTime.bottom+Ratio(35));
    
    self.imagePasosBack.centerXTop = XY(self.viewBack.width/2, self.btnAuth.bottom+Ratio(20));
    self.labelPasosTitle.leftTop = XY(Ratio(16), Ratio(16));
    NSArray * imageAry = @[@"iocn-home-autenticacion", @"iocn-home-revision", @"iocn-home-deposito"];
    NSArray * nameAry = @[@"Autenticación", @"Revisión rápida", @"Depósito inmediato"];
    for (int i = 0; i < nameAry.count; i ++) {
        UIImageView * image = [UIImageView new];
        image.widthHeight = XY(Ratio(36), Ratio(36));
        image.image = [UIImage imageNamed:imageAry[i]];
        image.centerXTop = XY(self.imagePasosBack.width/6*(1+2*i), self.labelPasosTitle.bottom+Ratio(22));
        [self.imagePasosBack addSubview:image];
        UILabel * label = [UILabel new];
        label.fontNum = 10;
        label.textColor = COLOR_CONTENT;
        [label fitTitle:nameAry[i] variable:0];
        label.centerXTop = XY(image.centerX, image.bottom+Ratio(8));
        [self.imagePasosBack addSubview:label];
        if(i > 0){
            UIImageView * imageDot = [UIImageView new];
            imageDot.image = [UIImage imageNamed:@"icon-dot-more"];
            imageDot.widthHeight = XY(28, 28);
            imageDot.centerXCenterY = XY(self.imagePasosBack.width/3*i, image.centerY);
            [self.imagePasosBack addSubview:imageDot];
        }
    }
    self.viewBack.height = self.imagePasosBack.bottom+Ratio(20);
    self.viewBack.centerXTop = XY(self.width/2, 0);
    self.height = self.viewBack.bottom+LEFT_MARDIN;
}




@end
